package com.dufang.ThreadWaitAndNotify;

/**
 * @ClassName:Test
 * @Description TODO
 * @Author Administrator
 * @Date 2025/7/7/007 16:04
 * @Version 1.0
 **/
public class Test {
    public static void main(String[] args) {

        BaoZiPu baoZiPu=new BaoZiPu();

        Product product=new Product(baoZiPu);
       // System.out.println(product.baoZiPu);com.dufang.ThreadWaitAndNotify.BaoZiPu@3b07d329
        Consumer consumer=new Consumer(baoZiPu);
        //System.out.println(consumer.baoZiPu);com.dufang.ThreadWaitAndNotify.BaoZiPu@404b9385

        /*Thread t1=new Thread(product);
        Thread t2=new Thread(consumer);

        t1.start();
        t2.start();*/
        //多条线程执行出现了连续生产和消费的情况  将生产和消费里面notifyAll()  if改为while
        // 比如生产完 生产锁生产完在重新判断flag
        new Thread(product).start();
        new Thread(consumer).start();
        new Thread(product).start();
        new Thread(consumer).start();
        new Thread(product).start();
        new Thread(consumer).start();
    }
}
